package com.alliky.core.net;

import com.alliky.core.base.IView;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

public class BaseConsumer<V extends IView> implements Consumer<Disposable> {

    V mView = null;
    boolean isLoading = true;

    public BaseConsumer(V view) {
        this.mView = view;
    }

    public BaseConsumer(V view, boolean isLoading) {
        this.mView = view;
        this.isLoading = isLoading;
    }

    @Override
    public void accept(Disposable disposable) throws Exception {
        if (mView != null) {
            if (isLoading) {
                mView.showLoading();
            }
        }
    }
}
